// 两列拖动改变两列宽度
export function dragAroundColDiv(boxClass, dragAroundLeft, resizeId, dragAroundRight) {
  resizeId.onmousedown = function (e) {
    let startX = e.clientX;
    resizeId.left = resizeId.offsetLeft;
    document.onmousemove = function (e) {
      let endX = e.clientX;
      let moveLen = resizeId.left + (endX - startX);
      let maxT = boxClass.clientWidth - resizeId.offsetWidth;
      if (moveLen < 150) moveLen = 150;
      if (moveLen > maxT - 150) moveLen = maxT - 150;
      resizeId.style.left = moveLen;
      dragAroundLeft.style.flex = 'none'
      dragAroundLeft.style.width = moveLen + 'px';
    }
    document.onmouseup = function () {
      document.onmousemove = null;
      document.onmouseup = null;
      resizeId.releaseCapture && resizeId.releaseCapture();
    }
    resizeId.setCapture && resizeId.setCapture();
    return false;
  }
}

// 上下拖动改变上下两个模块的高度
export function dragUdColDiv(boxClass, dragAroundTop, resizeId, dragAroundBottom) {
  let _this = this;
  let timer = null;
  resizeId.onmousedown = function (e) {
    let startY = e.clientY;
    resizeId.top = resizeId.offsetTop;
    document.onmousemove = function (e) {
      let endY = e.clientY;
      let moveLen = resizeId.top + (endY - startY);
      let maxT = boxClass.clientHeight - resizeId.offsetHeight;
      if (moveLen < 100) moveLen = 100;
      if (moveLen > maxT - 100) moveLen = maxT - 100;
      resizeId.style.top = moveLen;
      dragAroundTop.style.height = moveLen + "px";
      if (timer) {
        clearTimeout(timer)
      }
      timer = setTimeout(() => {
        dragAroundBottom.style.height = (boxClass.clientHeight - moveLen - 30) + "px";
        _this.$nextTick(() => {
          _this.parserTableHeight(_this.formConfCopy.fields);
        })
      }, 500)
    }
    document.onmouseup = function () {
      document.onmousemove = null;
      document.onmouseup = null;
      resizeId.releaseCapture && resizeId.releaseCapture();
    }
    resizeId.setCapture && resizeId.setCapture();
    return false;
  }
}
